import csv

def extract_keywords(input_file, output_file):
    """
    从CSV文件中提取关键词并保存到新文件
    """
    try:
        # 读取CSV文件
        with open(input_file, 'r', encoding='utf-8') as csvfile:
            reader = csv.DictReader(csvfile)
            keywords = []
            
            # 提取关键词
            for row in reader:
                keywords.append(row['Keyword'])
            
        # 将关键词写入新文件
        with open(output_file, 'w', encoding='utf-8') as outfile:
            for keyword in keywords:
                outfile.write(keyword + '\n')
                
        print(f"成功提取关键词并保存到 {output_file}")
        
    except Exception as e:
        print(f"发生错误: {str(e)}")

if __name__ == "__main__":
    input_file = 'flipclock.csv'
    output_file = 'keywords.txt'
    extract_keywords(input_file, output_file)
